var parameter = getRequest();
var jth = parameter['jth'];//参数名
var millName=parameter['millName'];


$(function () {

    //获取记录集
    getData();

    /*表格数据求和*/
    $('#waterdetai01').datagrid({
        showFooter:true,
        onLoadSuccess: function (data) {
            data = data.rows;
            var qty = 0;
            var ps=0;

            for (let i = 0; i < data.length; i++) {
                qty += data[i].b_qty ? parseFloat(data[i].b_qty) : 0;
                ps += data[i].b_ps ? parseFloat(data[i].b_ps) : 0;


            }
            $(this).datagrid('reloadFooter', [{
                b_processname: '合计',
                b_qty: qty.toFixed(1),
                b_ps: ps.toFixed(0)
            }])
        }
    })

})


function getData() {

    $.ajax({
        url: 'https://www.xdfznh.club/wxpadbe/execute/query/'
            + millName + '/'
            + "/call p_getjthprocessDetail('"
            + getUrlParam("SDate").substr(0,10)
            + "','"
            + getUrlParam("EDate").substr(0,10)
            + "',"
            + "'" + jth + "')",


        type: 'get',
        dataType: 'json',
        success: function (data) {
            $('#waterdetai01').datagrid('loadData', data);
        }
    })
}




//获取浏览器地址参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]);
    return null; //返回参数值
}

//获取浏览器地址参数（参数为中文）
function getRequest() {
    var url = window.location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
            //就是这句的问题
            theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]);
            //之前用了unescape()
            //才会出现乱码
        }
    }
    return theRequest;
}
